package com.situ.day22.annotatio;

import org.junit.Test;

import java.lang.reflect.Method;
import java.util.Arrays;

//@WebServlet("/student")
//@Author(value = "张三")
//@Author({"张三", "李四"})
@Author(value = "张三", name = "李四")
public class AuthorDemo {

    @Author
    private String name;

    @Author(name = "李四", age = 23, value = {"男", "女"})
    public void save() {

    }

    @Test
    public void test1() throws NoSuchMethodException {
        Class<AuthorDemo> clazz = AuthorDemo.class;
        Author typeAuthor = clazz.getAnnotation(Author.class);
        System.out.println(typeAuthor.name());
        System.out.println(typeAuthor.value()[0]);
        System.out.println(typeAuthor.age());

        Method method = clazz.getMethod("save");
        Author methodAuthor = method.getAnnotation(Author.class);
        System.out.println(methodAuthor.name());
        System.out.println(Arrays.toString(methodAuthor.value()));
        System.out.println(methodAuthor.age());
    }
}
